package com.android.djlmapp.adapter.order;

import android.text.TextUtils;

import static com.android.djlmapp.adapter.order.OrderListAdapter.COLOR_00ba23;
import static com.android.djlmapp.adapter.order.OrderListAdapter.COLOR_FF4081;
import static com.android.djlmapp.adapter.order.OrderListAdapter.COLOR_b9b9b9;
import static com.android.djlmapp.adapter.order.OrderListAdapter.COLOR_ff600a;
import static com.android.djlmapp.fragment.ChildOrderFragment.BROADBAND_ORDER_TYPE;
import static com.android.djlmapp.fragment.ChildOrderFragment.FLOW_CHARGE_ORDER_TYPE;
import static com.android.djlmapp.fragment.ChildOrderFragment.GAME_CHARGE_ORDER_TYPE;
import static com.android.djlmapp.fragment.ChildOrderFragment.KAIKA_ORDER_TYPE;
import static com.android.djlmapp.fragment.ChildOrderFragment.Q_MONEY_CHARGE_ORDER_TYPE;
import static com.android.djlmapp.fragment.ChildOrderFragment.TEL_CHARGE_ORDER_TYPE;
import static com.android.djlmapp.fragment.ChildOrderFragment.TERMINAL_ORDER_TYPE;

/**
 * @Author wangziheng
 * @ProjectName djlm
 * @ClassName OrderStatusAndType
 * @package com.android.djlmapp.adapter.order
 * @data 2019/1/24 19:05
 * @Describe
 *      所有的订单适配器 {@link OrderListAdapter}及其子类的{@link OrderListAdapter#getOrderStatusValue(String, String)}
 *      都可以删除掉，并转换到这个类里面来
 * * @Change
 */
public class OrderStatusAndType {


    /**
     * @param orderStatusCode 订单状态值
     * @param orderType       订单类型
     * @return
     */
    public static String[] getOrderStatus(String orderStatusCode, String orderType) {
        if (TextUtils.isEmpty(orderType)) {
            throw new NullPointerException("订单类型不能为空");
        }
        int orderTypeInt = Integer.valueOf(orderType);
        switch (orderTypeInt) {
            case KAIKA_ORDER_TYPE:
                return getKKOrderStatus(orderStatusCode);
            case TEL_CHARGE_ORDER_TYPE:
                return getTelChargeOrderStatus(orderStatusCode);
            case FLOW_CHARGE_ORDER_TYPE:
                return getTelChargeOrderStatus(orderStatusCode);
            case BROADBAND_ORDER_TYPE:
                return getBBOrderStatus(orderStatusCode);
            case TERMINAL_ORDER_TYPE:
                return getTerminalOrderStatus(orderStatusCode);
            case Q_MONEY_CHARGE_ORDER_TYPE:
            case GAME_CHARGE_ORDER_TYPE:
                return getDefaultOrderStatus(orderStatusCode);
            default:
                break;
        }
        return null;
    }

    /**
     * 获取开卡订单状态
     *
     * @param orderStatusCode
     * @return
     */
    private static String[] getKKOrderStatus(String orderStatusCode) {
        String[] orderStatusValue = new String[2];
        switch (orderStatusCode) {
            case "1":
                orderStatusValue[0] = "未付款";
                orderStatusValue[1] = COLOR_FF4081;
                break;
            case "2":
                orderStatusValue[0] = "已付款";
                orderStatusValue[1] = COLOR_ff600a;
                break;
            case "3":
                orderStatusValue[0] = "已完成";
                orderStatusValue[1] = COLOR_00ba23;
                break;
            case "4":
                orderStatusValue[0] = "已取消";
                orderStatusValue[1] = COLOR_b9b9b9;
                break;
            default:
                orderStatusValue[0] = "暂无状态";
                orderStatusValue[1] = COLOR_FF4081;
                break;
        }
        return orderStatusValue;
    }

    /**
     * 获取充值订单状态
     *
     * @param orderStatusCode
     * @return
     */
    private static String[] getTelChargeOrderStatus(String orderStatusCode) {
        String[] orderStatusValue = new String[2];
        switch (orderStatusCode) {
            case "2":
            case "4":
            case "6":
            case "9":
                orderStatusValue[0] = "处理中";
                orderStatusValue[1] = COLOR_ff600a;
                break;
            case "5":
                orderStatusValue[0] = "已完成";
                orderStatusValue[1] = COLOR_00ba23;
                break;
            case "7":
                orderStatusValue[0] = "已退款";
                orderStatusValue[1] = COLOR_b9b9b9;
                break;
            default:
                orderStatusValue[0] = "暂无状态";
                orderStatusValue[1] = COLOR_FF4081;
                break;
        }
        return orderStatusValue;
    }

    /**
     * 获取宽带订单状态
     *
     * @param orderStatusCode
     * @return
     */
    private static String[] getBBOrderStatus(String orderStatusCode) {
        String[] orderStatusValue = new String[2];
        switch (orderStatusCode) {
            case "1":
                orderStatusValue[0] = "未付款";
                orderStatusValue[1] = COLOR_FF4081;
                break;
            case "2":
            case "5":
                orderStatusValue[0] = "处理中";
                orderStatusValue[1] = COLOR_ff600a;
                break;
            case "3":
                orderStatusValue[0] = "已完成";
                orderStatusValue[1] = COLOR_00ba23;
                break;
            case "4":
                orderStatusValue[0] = "已取消";
                orderStatusValue[1] = COLOR_b9b9b9;
                break;
            default:
                orderStatusValue[0] = "暂无状态";
                orderStatusValue[1] = COLOR_FF4081;
                break;
        }
        return orderStatusValue;
    }

    /**
     * 获取终端订单状态
     *
     * @param orderStatusCode
     * @return
     */
    private static String[] getTerminalOrderStatus(String orderStatusCode) {
        String[] orderStatusValue = new String[2];
        switch (orderStatusCode) {
            case "1":
                orderStatusValue[0] = "已提交";
                orderStatusValue[1] = COLOR_FF4081;
                break;
            case "2":
                orderStatusValue[0] = "已付款";
                orderStatusValue[1] = COLOR_ff600a;
                break;
            case "3":
                orderStatusValue[0] = "已发货";
                orderStatusValue[1] = COLOR_ff600a;
                break;
            case "4":
                orderStatusValue[0] = "已完成";
                orderStatusValue[1] = COLOR_00ba23;
                break;
            case "5":
                orderStatusValue[0] = "已取消";
                orderStatusValue[1] = COLOR_b9b9b9;
                break;
            default:
                orderStatusValue[0] = "暂无状态";
                orderStatusValue[1] = COLOR_FF4081;
                break;
        }
        return orderStatusValue;
    }

    /**
     * 获取默认订单状态
     *
     * @param orderStatusCode
     * @return
     */
    private static String[] getDefaultOrderStatus(String orderStatusCode) {
        String[] orderValue = new String[2];
        switch (orderStatusCode) {
            case "2":
            case "4":
            case "6":
            case "9":
                orderValue[0] = "处理中";
                orderValue[1] = COLOR_ff600a;
                break;
            case "5":
                orderValue[0] = "已完成";
                orderValue[1] = COLOR_00ba23;
                break;
            case "7":
                orderValue[0] = "已取消";
                orderValue[1] = COLOR_b9b9b9;
                break;
            default:
                orderValue[0] = "暂无状态";
                orderValue[1] = COLOR_FF4081;
                break;
        }
        return orderValue;
    }
}
